﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CrmContacto.Contracts.Promociones;
using CrmContacto.WebApp.App;
using Web.CrmContacto.Code;

namespace CrmContacto.WebApp.Code.InnerClasses.FrontEnd.Promociones
{
    [Serializable]
    public class PromocionWebBase : IPromocionWebStrategy
    {
        public int EmpresaId { get; set; }

        public int PromocionId { get; set; }

        public virtual void LoadExtraControls(System.Web.UI.WebControls.Panel panel)
        {

        }

        public virtual bool UsaCupon
        {
            get
            {
                return true;
            }
        }

        public virtual ParticipantesSearch GetParticipantesSearch(ReporteParticipantesPosiblesEnPromocion page)
        {
            ParticipantesSearch search = new ParticipantesSearch();
            search.EmpresaId = this.EmpresaId;
            search.PromocionId = this.PromocionId;
            search.AplicaCuponId = page.AplicaCupon;

            if (!String.IsNullOrEmpty(page.ContactosText))
            {
                var emails = page.ContactosText.Split(',');
                foreach (var em in emails)
                {
                    search.EmailList.Add(em.Trim());
                }
            }

            return search;
        }
    }
}